/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package functionalEnrichment.semanticSimilarity.semanticSimilarityCalculator.units;

import java.util.Arrays;

/**
 *
 * @author jamie
 */
public class GoTermPair implements Comparable{

    private GoTerm goTerm1;
    private GoTerm goTerm2;
    private String uniqueId;

    public GoTermPair(GoTerm goTerm1, GoTerm goTerm2) {
        GoTerm[] terms = {goTerm1, goTerm2};
        Arrays.sort(terms);
        uniqueId = terms[0].getId()+"_"+terms[1].getId();
        this.goTerm1 = terms[0];
        this.goTerm2 = terms[1];
    }

    public GoTerm getGoTerm1() {
        return goTerm1;
    }

    public GoTerm getGoTerm2() {
        return goTerm2;
    }

    public String getUniqueId() {
        return uniqueId;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GoTermPair other = (GoTermPair) obj;
        if ((this.uniqueId == null) ? (other.uniqueId != null) : !this.uniqueId.equals(other.uniqueId)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 67 * hash + (this.uniqueId != null ? this.uniqueId.hashCode() : 0);
        return hash;
    }

    public int compareTo(Object o) {
        GoTermPair gtp_other = (GoTermPair) o;
        return this.getUniqueId().compareTo(gtp_other.getUniqueId());
    }



    










}
